<template>
  <div class="content-box">
    <nav-title title="竞业协议信息" />
    <edit-option-line label="是否签署协议" :vals="ynList" v-model="jyxy.cIsJyxy"></edit-option-line>
    <edit-option-line label="协议是否有效" :vals="ynList" v-model="jyxy.cIsJyxyStatus"></edit-option-line>
    <edit-line label="化名" v-model="jyxy.cNameAs"></edit-line>
    <div class="bsbtn" @click="save">保存</div>
  </div>

</template>

<script>
import EditLine from '../../../../components/basic/EditLine'
import EditOptionLine from '../../../../components/basic/EditOptionLine'
import { getJyxy, saveJyxy} from '../../../../api/api'
import { json2Form } from '../../../../util/http'

export default {

  name: 'input-information',
  components: {
    EditLine,EditOptionLine
  },
  mounted(){
    // if(this.$store.state.hid){
    //   this.outf.rsHireId = this.$store.state.hid
    // }
  },
  data() {
    return {
      ynList: [{value: '是', key: 'Y'},{value: '否', key: 'N'}],
      jyxy:{}
    }
  },
  created() {
    this.getJyxy()
  },
  methods: {
    save() {
      var that = this
      console.log(this.jyxy)
      if(!this.jyxy.cIsJyxy &&
        !this.jyxy.cIsJyxyStatus && !this.jyxy.cNameAs) {
          this.$vux.alert.show({
            title: '提示',
            content: '请填写至少一个项目'
          })
          return;
      }
      saveJyxy(json2Form(that.jyxy)).then(res => {
        if(res && res.retCode === '000000' ){
          //保存成功
          this.$vux.alert.show({
            title: '提示',
            content: '保存成功',
            onHide () {
              that.$router.push('/informationCollection/userInfo');
            }
          })

        }else{
          // 显示
          this.$vux.alert.show({
            title: '提示',
            content: res.retMsg
          })
        }
      }).catch (res=>{
        this.$vux.alert.show({
          title: '警告',
          content: '网络异常，请稍后重试'
        })
      })
    },

    getJyxy() {
      if(this.$route.params.jyxy){
        this.jyxy = this.$route.params.jyxy
      }
      console.log(this.$route.params)
    }
  },
  watch: {
    '$route': 'getBsif'
  }
}
</script>
<style type="text/scss" lang="scss">
  @import "./editinfo";
</style>
